//
//  ViewController.m
//  瀑布流视图
//
//  Created by 梅毅 on 2017/7/31.
//  Copyright © 2017年 my. All rights reserved.
//

#import "ViewController.h"
#import "MYCollectionViewLayout.h"
#import "UIColor+randomColor.h"
#import "MyCollectionViewCell.h"

@interface ViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>

@property (nonatomic, strong) UICollectionView  *collectionView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    MYCollectionViewLayout *MyLayout = [[MYCollectionViewLayout alloc] init];
    MyLayout.columnCount = 3;
    _collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:MyLayout];
    _collectionView.backgroundColor = [UIColor whiteColor];
    [_collectionView registerNib:[UINib nibWithNibName:@"MyCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"Cell"];
    _collectionView.delegate = self;
    _collectionView.dataSource = self;
    
    [self.view addSubview:_collectionView];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark - UICollectionViewDelegate && UICollectionViewDataSource
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 100;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    MyCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
    cell.ImgView.backgroundColor = [UIColor randomColor];
    
    return cell;
}

@end
